<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" placeholder="请输入1~100之间的整数" v-model="num"/>
    <input type="button" value="猜一猜" @click="f()"/>
    <h3>结果：{{result}}</h3>
</div>
</body>
<script src="js/vue.min.js"></script>
<script>

    let v = new Vue({
        el:"body>div",
        data:{
            num:"",result:"",count:0,
            ranNum:parseInt(Math.random()*100+1)
        },
        methods:{
            f(){
                v.count++;
                if(v.num>v.ranNum){
                    v.result = "猜大了";
                }else if(v.num<v.ranNum){
                    v.result = "猜小了";
                }else{
                    v.result = "第"+v.count+"次猜对了";
                }
            }
        }
    });
    console.log(v.ranNum);

</script>
</html>